﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lilium.LParse.TextExtensions
{
    public static class StringExtensions
    {
        /// <summary>
        /// Synonym for <see cref="TextParsers.OneOf"/> parser.
        /// </summary>
        public static Parser<char, char> Any(this string chars)
        {
            return TextParsers.OneOf(chars);
        }

        /// <summary>
        /// Synonym for <see cref="TextParsers.Find"/> parser.
        /// </summary>
        public static Parser<char, string> Find(this string word)
        {
            return TextParsers.Find(word);
        }

        /// <summary>
        /// Synonym for <see cref="TextParsers.Word"/> parser.
        /// </summary>
        public static Parser<char, string> Match(this string word)
        {
            return TextParsers.Word(word);
        }

        /// <summary>
        /// Consumes any symbols till the specified word.
        /// 
        /// </summary>
        public static Parser<char, string> Till(this string word)
        {   //TODO: переписать на КМП.
            return TextParsers.ManyTill(TextParsers.TryWord(word));
        }
    }
}
